import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutterdemo/0demo/provider/02my_demo/provider_data/common_data.dart';

class SharedData with ChangeNotifier {
  UserModel _userModel;
  GoodModel _goodModel;

  void updateUserModel() {
    UserModel userModel = UserModel();
    userModel.name = Random().nextInt(1000).toString();
    userModel.age = Random().nextInt(100);
    _userModel = userModel;
    notifyListeners();
  }

  void updateGoodModel() {
    GoodModel goodModel = GoodModel();
    goodModel.goodName = Random().nextInt(1000).toString();
    goodModel.goodPrice = Random().nextInt(100);
    _goodModel = goodModel;
    notifyListeners();
  }

  get userModel => _userModel;

  get goodModel => _goodModel;

  @override
  String toString() {
    return 'SharedData{userModel: $userModel, goodModel: $goodModel}';
  }
}

class GoodModel {
  String goodName;
  int goodPrice;

  @override
  String toString() {
    return 'GoodModel{goodName: $goodName, goodPrice: $goodPrice}';
  }
}
